<!doctype html>
<html>
<head>
    <meta charset=utf-8>
    <title></title>
    <meta name="robots" content="noindex,nofollow">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="<?=Web_Path?>packs/layui/css/layui.css">
    <link rel="stylesheet" href="<?=Web_Path?>packs/admin/css/font.css">
    <link rel="stylesheet" href="<?=Web_Path?>packs/admin/css/style.css">
    <script src="<?=Web_Path?>packs/js/jquery.min.js"></script>
    <script src="<?=Web_Path?>packs/layui/layui.js"></script>
    <script src="<?=Web_Path?>packs/admin/js/cscms.js"></script>
</head>
<body id="index_setting">
    <span class="layui-breadcrumb" >
        <a ><cite><i class="fa fa-map-marker"></i><?=L('tpl_dd_01')?></cite></a>
        <a href="javascript:;"><?=L('tpl_dd_02')?></a>
        <a href="<?=site_url('label/deldata')?>"><?=L('tpl_dd_03')?></a>
    </span>
    <form class="layui-form layui-form-pane" action="<?=site_url('label/deldata_save')?>" method="post">
        <fieldset class="layui-elem-field" style="margin-top: 15px;">
            <legend><?=L('tpl_dd_03')?></legend>
            <div class="layui-field-box">
                <div class="layui-form-item">
                    <label class="layui-form-label"><?=L('tpl_dd_04')?></label>
                    <div class="layui-input-inline">
                        <select name="dir" lay-filter="plugins">
                            <option value="1"><?=L('tpl_dd_05')?></option>
                            <?php 
                                $i=2;
                                foreach ($plugins as $row) {
                                    echo '<option value="'.$i.'">'.$row->name.'('.$row->dir.')</option>';
                                    $i++;
                                }
                            ?>
                        </select>
                    </div>
                </div>
                <div class="layui-form-item dir dir1">
                    <label class="layui-form-label"><?=L('tpl_dd_06')?></label>
                    <div class="layui-input-inline">
                        <select name="table_1">
                            <option value=""><?=L('tpl_dd_06')?></option>
                            <option value="link"><?=L('tpl_dd_07')?></option>
                            <option value="user"><?=L('tpl_dd_08')?></option>
                            <option value="user_log"><?=L('tpl_dd_09')?></option>
                            <option value="blog"><?=L('tpl_dd_10')?></option>
                            <option value="funco"><?=L('tpl_dd_11')?></option>
                            <option value="fans"><?=L('tpl_dd_12')?></option>
                            <option value="friend"><?=L('tpl_dd_13')?></option>
                            <option value="gbook"><?=L('tpl_dd_14')?></option>
                            <option value="dt"><?=L('tpl_dd_15')?></option>
                            <option value="msg"><?=L('tpl_dd_16')?></option>
                            <option value="pl"><?=L('tpl_dd_17')?></option>
                        </select>
                    </div>
                </div>
                <?php 
                $i=2;
                foreach ($plugins as $row) {
                  if(file_exists(CSCMS.$row->dir.FGF.'install.php')){
                     $SQLDB = require_once(CSCMS.$row->dir.FGF.'install.php');
                     echo '<div class="layui-form-item dir dir'.$i.'" style="display: none;"><label class="layui-form-label">'.L('tpl_dd_18').'</label><div class="layui-input-inline"><select name="table_'.$i.'"><option value="">'.L('tpl_dd_18').'</option>';
                     //判断数据库
                     if(is_array($SQLDB)){
                            foreach ($SQLDB as $sql) {
                                  preg_match('/CREATE TABLE IF NOT EXISTS `{prefix}([\s\S]+?)`([\s\S]+?)COMMENT=\'([\s\S]+?)\';/',$sql,$tarr);
                                  if(!empty($tarr[1]) && $this->db->table_exists(CS_SqlPrefix.$tarr[1])){
                                          $tname=!empty($tarr[3])?$tarr[3]:$tarr[1];
                                          echo '<option value="'.$tarr[1].'">'.$tname.'</option>';
                                  }
                            }
                     }else{
                            preg_match('/CREATE TABLE IF NOT EXISTS `{prefix}([\s\S]+?)`([\s\S]+?)COMMENT=\'([\s\S]+?)\';/',$SQLDB,$tarr);
                            if(!empty($tarr[1]) && $this->db->table_exists(CS_SqlPrefix.$tarr[1])){
                                   $tname=!empty($tarr[3])?$tarr[3]:$tarr[1];
                                   echo '<option value="'.$tarr[1].'">'.$tname.'</option>';
                            }
                     }
                     echo '</select></div></div>';
                  }
                $i++;
                }
                ?>
                <div class="layui-form-item">
                    <label class="layui-form-label"><?=L('tpl_dd_19')?></label>
                    <div class="layui-input-inline">
                          <input type="checkbox" name="ids" lay-skin="primary" value="ok" title="<?=L('tpl_dd_20')?>" checked>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block noborder">
                        <button style="margin-left: 20%;" class="layui-btn" lay-submit lay-filter="setting"><?=L('tpl_dd_21')?></button>
                        <button type="reset" class="layui-btn layui-btn-primary"><?=L('tpl_dd_22')?></button>
                    </div>
                </div>
            </div>
        </fieldset>
    </form>
    <script type="text/javascript">
        cscms.init();
    </script>
</body>
</html>